/**
 * Willen Goulart
 * 
 * Copyright (c) 2011
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */

package br.usp.ime.ingpos.modelo;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Parameter;

@Entity
public class Candidato extends Usuario implements Serializable {

	private static final long serialVersionUID = 4854406994257619034L;

	@OneToOne
	@Cascade({ CascadeType.ALL })
	private Curriculo curriculo;

	@OneToMany(fetch=FetchType.EAGER)
	@JoinColumn(name = "usuarioId", referencedColumnName = "usuarioId")
	@Cascade({ CascadeType.ALL })
	private Set<Inscricao> inscricoes;
	
	public Candidato() {
		super();
	}
	
	public Candidato(Usuario usuario) {
		super(usuario);
	}

	public Curriculo getCurriculo() 
	{
		return curriculo;
	}

	/* Setters */
	public void setCurriculo(Curriculo curriculo) 
	{
		this.curriculo = curriculo;
	}

	public Set<Inscricao> getInscricoes() 
	{
		return inscricoes;
	}

	public void setInscricoes(Set<Inscricao> inscricoes) 
	{
		this.inscricoes = inscricoes;
	}

	/**
	 * Inclusao de inscricao do candidato
	 * @param inscricao Objeto que representa a inscricao 
	 */
	public void insereInscricao(Inscricao inscricao) 
	{
		if (this.inscricoes == null)
			this.inscricoes = new HashSet<Inscricao>();

		this.inscricoes.add(inscricao);
	}
}
